package com.yootk.config;

import com.yootk.editor.AddressPropertyEditorRegistrar;
import com.yootk.vo.Company;
import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.factory.config.CustomEditorConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource("classpath:props/company.properties")   // 资源引入
public class CompanyConfiguration {

    @Bean
    public Company company() {
        return new Company();
    }

    @Bean
    public CustomEditorConfigurer customEditorConfigurer() {
        CustomEditorConfigurer configurer = new CustomEditorConfigurer();
        configurer.setPropertyEditorRegistrars(new PropertyEditorRegistrar[] {
                new AddressPropertyEditorRegistrar()    // 注册属性编辑器
        });
        return configurer;
    }
}
